package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.TkmGastroscopeDiagnosisInfo;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.SysUserService;
import com.zjcode.cdcer.service.TkmGastroscopeDiagnosisInfoService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:TkmGastroscopeDiagnosisInfoController
 * @功能：胃镜诊疗总量
 * @author：wlei
 * @日期：2022/7/27-00:56
 **/
@RestController
@Slf4j
@RequestMapping("/v1/gastroscopediagnosis/")
public class TkmGastroscopeDiagnosisInfoController extends BaseController {

    @Autowired
    private TkmGastroscopeDiagnosisInfoService diagnosisInfoService;
    @Autowired
    private SysUserService sysUserService;

    /**
     * 更新数据
     *
     * @param pageData
     * @return
     */
    @PostMapping("updateRecords")
    public JsonObj updateRecords(@RequestBody PageData pageData) {
        int records = diagnosisInfoService.updateRecords(pageData);
        Map<String, Object> data = new HashMap<>();
        data.put("records", records);
        return JsonObj.success(data);
    }

    @PostMapping("listAllByUser")
    public JsonObj listAllByUser(@RequestBody PageData pageData) {
        List<TkmGastroscopeDiagnosisInfo> infos = diagnosisInfoService.listAll(pageData);
        Map<String, Object> data = new HashMap<>();
        data.put("list", infos);
        return JsonObj.success(data);
    }
}
